#pragma once

#include <vector>
#include "oratypes.h"
#include "oci.h"
#include "FMDBRecordSet.h"

class FMDBParameter
{
public:
	FMDBParameter(char *VarName,int *VarValueArray);
	FMDBParameter(char *VarName,long *VarValueArray);
	FMDBParameter(char *VarName,char *VarValueArray);
	FMDBParameter(char *VarName,double *VarValueArray);

	~FMDBParameter(void);
	FMDBParameter(void);
	void Set(char *VarName,int *VarValueArray);
	void Set(char *VarName,long *VarValueArray);
	void Set(char *VarName,char *VarValueArray);
	void Set(char *VarName,double *VarValueArray);

	char* GetVarName(){return m_pstrVarName;}
	ub2 GetVarOraDataType(){return m_VarDataType;}
	(void *)GetVarValue(){return m_VarValue;}
	void SetIndicator(short* val){m_pIndicator=val;}
	short* GetIndicator(){return m_pIndicator;}
	ub4 GetVarSize(){return m_VarSize;}
	void SetVarSize(ub4 val){ m_VarSize=val;}

private:
	char *m_pstrVarName;
	void *m_VarValue;
	ub2 m_VarDataType;
	short *m_pIndicator;
	ub4 m_VarSize;
};

class FMDBIOVParameter
{
public:
	FMDBIOVParameter(char *VarName,OCIIOV *VarValueArray,ub4 ArraySize,ub2 VarOraDataType);
	~FMDBIOVParameter(void){}
	char* GetVarName()
	{
		return m_pstrVarName;
	}
	ub2 GetVarOraDataType()
	{
		return m_VarDataType;
	}
	ub4 GetVarArraySize()
	{
		return m_ValueArraySize;
	}
	(OCIIOV *)GetVarValue()
	{
		return m_VarValue;
	}

private:
	char *m_pstrVarName;
	OCIIOV *m_VarValue;
	ub4 m_ValueArraySize;
	ub2 m_VarDataType;

};

class FMDBCursorParameter
{
public:
	FMDBCursorParameter(char *VarName,OCIStmt *VarValue,FMDBRecordSet *Rs=NULL);
	~FMDBCursorParameter(void);

	char* GetVarName(){return m_pstrVarName;}
	ub2 GetVarOraDataType(){return SQLT_RSET;}
	void* GetVarValue()
	{
		return m_VarValue;
	}
	void SetVarValue(void *val){m_VarValue=val;}
	FMDBRecordSet * GetRecordset() const { return m_pRs; }
	void SetRecordset(FMDBRecordSet * val) { m_pRs = val; }
private:
	char *m_pstrVarName;
	void *m_VarValue;//this is a pointer to OCIStmt handle
	FMDBRecordSet *m_pRs;//recordset for this oci parameter statement
};

class FMDBParameters
{
public:
	FMDBParameters(void){};
	~FMDBParameters(void);

	void AddParam(FMDBParameter *Param);
	void AddOCIIOVParam(FMDBIOVParameter *Param);
	void AddCursorParam(FMDBCursorParameter *Param);

	std::vector<FMDBParameter *> GetParameters(){return m_vParam;}
	std::vector<FMDBIOVParameter *> GetIOVParameters(){return m_vIOVParam;}
	std::vector<FMDBCursorParameter *> GetCursorParameters(){return m_vCursorParam;}
	
private:
	std::vector<FMDBParameter *> m_vParam;
	std::vector<FMDBIOVParameter *> m_vIOVParam;
	std::vector<FMDBCursorParameter *> m_vCursorParam;
};